Skip to main content

GPG AES-256 File Decryption

Description

The decrypt_file_gpg_aes256 function decrypts a GPG-encrypted file using AES-256 encryption, supporting both Windows and Linux platforms. It requires the encrypted .gpg file and a password to successfully decrypt the content.

Function Signature:

def decrypt_file_gpg_aes256(encrypted_file_path: str, password: str) -> str:

Parameters

  • encrypted_file_path (str): Full path to the encrypted .gpg file.
  • password (str): The password used for decryption.

Returns

  • str: The full path to the decrypted file.

Example Usage

decrypted_file = decrypt_file_gpg_aes256("/path/to/encrypted_file.gpg", "your_password")
print(f"Decrypted file saved to: {decrypted_file}")

Notes

  • The function uses the AES-256 encryption algorithm with GPG.
  • The .gpg extension is removed from the encrypted file to derive the decrypted file's path.
  • The function raises an error if the encrypted file is not found or if the decryption fails.

Error Handling

  • FileNotFoundError: Raised if the encrypted file does not exist.
  • RuntimeError: Raised if the decryption fails or if the decrypted file is not created.